<#assign base=request.contextPath />
<!doctype html>
<html lang="en" class="fixed accounts sign-in">

<head>
    <meta charset="UTF-8">
    <title>Ikaros</title>
    <#include "commons/headImport.ftl">
</head>

<body>

<div class="wrap">
    <div class="page-body animated slideInDown">
        <div class="logo">
            <img alt="logo" src="${base}/static/images/logo-dark.png" />
        </div>
        <div class="box">
            <div class="panel mb-none">
                <div class="panel-content bg-scale-0">
                    <form id="login_app">
                        <div class="form-group mt-md">
                            <span class="input-with-icon">
                                    <input type="text" class="form-control" placeholder="用户名" v-model="username">
                                    <i class="fa fa-envelope"></i>
                            </span>
                        </div>
                        <div class="form-group">
                                <span class="input-with-icon">
                                        <input type="password" class="form-control" placeholder="密码" v-model="password">
                                        <i class="fa fa-key"></i>
                                </span>
                        </div>
                        <div class="form-group">
                            <div class="checkbox-custom checkbox-primary">
                                <label>
                                    <input type="checkbox" value="1" style="opacity:0.8;margin-left:0;" >
                                    <span style="margin-left:20px">记住用户 </span>
                                </label>
                                <div id="msg" style="float:right; margin-right:35%; color:red">
                                    {{msg}}
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <a class="btn btn-primary btn-block" v-on:click="login">登录</a>
                        </div>
                        <div class="form-group text-center">
                            <a>忘记密码</a>
                        </div>
                    </form>

                </div>
            </div>
        </div>
    </div>
</div>

</body>
<script src="${base}/static/javascripts/jquery.min.js"></script>
<script src="${base}/static/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="${base}/static/javascripts/vue.min.js"></script>
<script src="${base}/static/vendor/nano-scroller/nano-scroller.js"></script>
<script src="${base}/static/javascripts/template-script.min.js"></script>
<script src="${base}/static/javascripts/template-init.min.js"></script>
<script src="${base}/static/javascripts/axios.min.js"></script>
<script>
var login=new Vue({
        el: '#login_app',
        data: {
            username:'',
            password:'',
            msg:''
        },
        methods: {
            login: function () {
                //这样可以吧data中的数据用that.msg=xx设置
                var that = this
                axios.post('${base}/login', {
                    username: this.username,
                    password: this.password
                }).then(function (result) {
                    /*{data: {…}, status: 200, statusText: "", headers: {…}, config: {…}, …}*/
                    console.log(result.data.code)
                    if (result.data.code!=1){
                       that.msg=result.data.msg;
                    }else{
                        parent.location.href = '${base}/index';
                    }
                })
                .catch(function (error) {
                    console.log(error);
                });
            }
        }
    })
</script>
</html>
